# Include the directory itself as a path to include directories
set( CMAKE_INCLUDE_CURRENT_DIR ON )

# Add Horde3D search path (TODO: Fix this)
set( Horde3D_PKGCONF_LIBRARY_DIRS ${PROJECT_BINARY_DIR}/../lib/mac/Library )

# Add requirements for external libraries
find_package( SDL REQUIRED )
find_package( Lua51 REQUIRED )
find_package( Horde3D REQUIRED )
include_directories( ${SDL_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${Horde3D_INCLUDE_DIR} )

# Create a variable containing all .cpp files
file( GLOB pl_horde3d_SOURCES *.cpp )

# Create a variable containing all .h files
file( GLOB pl_horde3d_HEADERS *.h )

# Create a library for this module
add_library( pl_horde3d ${pl_horde3d_SOURCES} ${pl_horde3d_HEADERS} ${pl_horde3d_LUA_TGTS} )

# Set up other dependencies
target_link_libraries( pl_horde3d ${CMAKE_DL_LIBS} )
target_link_libraries( pl_horde3d ${SDL_LIBRARY} ) 
target_link_libraries( pl_horde3d ${LUA_LIBRARIES} ) 
target_link_libraries( pl_horde3d ${Horde3D_LIBRARIES} )

# Set up installation targets
install( FILES ${pl_horde3d_LUA_TGTS} DESTINATION bin/horde3d )
